package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {

    //根据分类id进行查询菜品数量
    @Select("select count(*) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);
    //新增菜品
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);
    //菜品分页查询
    List<DishVO> queryByPage(DishPageQueryDTO dishPageQueryDTO);
    //根据id删除菜品
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);
    //修改菜品
    @AutoFill(value = OperationType.UPDATE)
    void updateById(Dish dish);

    @Select("select * from dish where category_id = #{category_id}")
    List<Dish> queryByCategoryId(Long categoryId);

    List<Dish> queryBySetMealId(Long setmealId);

    List<DishVO> queryByCategoryIdWithFlavor(Long categoryId);
    @Select("select * from dish where id = #{id}")
    Dish getDishById(Long id);

    @Select("select count(id) from dish where status = #{status}")
    Integer getDishCount(Integer status);
}
